/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bungabungaball;

import org.newdawn.slick.*;
import org.newdawn.slick.state.StateBasedGame;
import bungabungaball.gamestates.GamePlay;
import bungabungaball.gamestates.JoinNetworkGame;
import bungabungaball.gamestates.MainMenu;
import bungabungaball.gamestates.MenuOption;
import bungabungaball.gamestates.GameEnd;
import bungabungaball.gamestates.StartNetworkGame;
import bungabungaball.gamestates.LevelEditor;
import bungabungaball.gamestates.SpecificGame;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.lwjgl.openal.AL;

/**
 * BungaBungaBall is the main class and defines the container and the basic gamestates.
 *
 * @author Ingo Klose, Stephan Meyer, Sebastian Lehmann
 * @version 1.0
 *
 */
public class BungaBungaBall extends StateBasedGame  {

    /**
     * The StateID of the main menu
     */
    public static final int MAINMENUSTATE             = 0;
    /**
     * The StateID of the option menu
     */
    public static final int OPTIONPLAYSTATE           = 1;
    /**
     * The StateID of the real game
     */
    public static final int GAMEPLAYSTATESingle       = 2;
    /**
     * The StateID of the start network game
     */
    public static final int GAMEPLAYSTATESTARTNETWORK = 3;
    /**
     * The StateID of the join network game
     */
    public static final int GAMEPLAYSTATEJOINNETWORK    = 4;
    /**
     * The StateID of the end game state
     */
    public static final int GAMEENDPLAYSTATE            =5;
    /**
     * The StateID of the level editor
     */
    public static final int LEVELEDITOR                 =6;
    /**
     * The StateID of the specific Gameplay
     */
    public static final int GAMEPLAYSTATESpecific                 =7;
    /**
     * The basic gameplay
     */
    public static GamePlay gameplay;
    
    /**
     * Constructor
     */
    public BungaBungaBall() {
        super("Bunga Bunga Ball");
    }

    /**
     * The Main function, starts the game
     * @param args
     * @throws SlickException
     */
    public static void main(String[] args) throws SlickException {
        AppGameContainer app = new AppGameContainer(new BungaBungaBall());
        app.setDisplayMode(GlobalSettings.windowSizeX, GlobalSettings.windowSizeY, false);
        app.setTargetFrameRate(30);
        app.setAlwaysRender(true);
        app.start();
        AL.destroy();
        
    }
    
    /**
     * Init all game States, to that they are known by Slick2d
     * @param gameContainer
     * @throws SlickException
     */
    @Override
    public void initStatesList(GameContainer gameContainer) throws SlickException {
        try {
            //this.addState(new MainMenuState(MAINMENUSTATE));
            gameplay = new GamePlay(GAMEPLAYSTATESingle);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(BungaBungaBall.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(BungaBungaBall.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.addState(new MainMenu(MAINMENUSTATE));
        this.addState(new MenuOption(OPTIONPLAYSTATE));
        this.addState(gameplay);
        this.addState(new StartNetworkGame(GAMEPLAYSTATESTARTNETWORK));
        this.addState(new JoinNetworkGame(GAMEPLAYSTATEJOINNETWORK));
        this.addState(new GameEnd(GAMEENDPLAYSTATE));
        this.addState(new LevelEditor(LEVELEDITOR));
        this.addState(new SpecificGame(GAMEPLAYSTATESpecific));
    }
}